package edu.unf.cen6940.service;

import edu.unf.cen6940.domain.Facultyresearch;
import edu.unf.cen6940.domain.Researchkeyword;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/rms_test-security-context.xml",
		"file:./resources/rms_test-service-context.xml",
		"file:./resources/rms_test-dao-context.xml",
		"file:./resources/rms_test-web-context.xml" })
@Transactional
public class ResearchkeywordServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected ResearchkeywordService service;

	/**
	 * Instantiates a new ResearchkeywordServiceTest.
	 *
	 */
	public ResearchkeywordServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Researchkeyword entity
	 * 
	 */
	@Test
	public void deleteResearchkeyword() {
		// TODO: JUnit - Populate test inputs for operation: deleteResearchkeyword 
		Researchkeyword researchkeyword = new edu.unf.cen6940.domain.Researchkeyword();
		service.deleteResearchkeyword(researchkeyword);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Facultyresearch entity
	 * 
	 */
	@Test
	public void deleteResearchkeywordFacultyresearchs() {
		// TODO: JUnit - Populate test inputs for operation: deleteResearchkeywordFacultyresearchs 
		Integer researchkeyword_researchKeywordId = 0;
		Integer related_facultyresearchs_facultyResearchId = 0;
		Researchkeyword response = null;
		response = service.deleteResearchkeywordFacultyresearchs(researchkeyword_researchKeywordId, related_facultyresearchs_facultyResearchId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteResearchkeywordFacultyresearchs
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Researchkeyword entity
	 * 
	 */
	@Test
	public void countResearchkeywords() {
		Integer response = null;
		response = service.countResearchkeywords();
		// TODO: JUnit - Add assertions to test outputs of operation: countResearchkeywords
	}

	/**
	 * Operation Unit Test
	 * Save an existing Researchkeyword entity
	 * 
	 */
	@Test
	public void saveResearchkeyword() {
		// TODO: JUnit - Populate test inputs for operation: saveResearchkeyword 
		Researchkeyword researchkeyword_1 = new edu.unf.cen6940.domain.Researchkeyword();
		service.saveResearchkeyword(researchkeyword_1);
	}

	/**
	 * Operation Unit Test
	 * Return all Researchkeyword entity
	 * 
	 */
	@Test
	public void findAllResearchkeywords() {
		// TODO: JUnit - Populate test inputs for operation: findAllResearchkeywords 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Researchkeyword> response = null;
		response = service.findAllResearchkeywords(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllResearchkeywords
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findResearchkeywordByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findResearchkeywordByPrimaryKey 
		Integer researchKeywordId = 0;
		Researchkeyword response = null;
		response = service.findResearchkeywordByPrimaryKey(researchKeywordId);
		// TODO: JUnit - Add assertions to test outputs of operation: findResearchkeywordByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Save an existing Facultyresearch entity
	 * 
	 */
	@Test
	public void saveResearchkeywordFacultyresearchs() {
		// TODO: JUnit - Populate test inputs for operation: saveResearchkeywordFacultyresearchs 
		Integer researchKeywordId_1 = 0;
		Facultyresearch related_facultyresearchs = new edu.unf.cen6940.domain.Facultyresearch();
		Researchkeyword response = null;
		response = service.saveResearchkeywordFacultyresearchs(researchKeywordId_1, related_facultyresearchs);
		// TODO: JUnit - Add assertions to test outputs of operation: saveResearchkeywordFacultyresearchs
	}

	/**
	 * Operation Unit Test
	 * Load an existing Researchkeyword entity
	 * 
	 */
	@Test
	public void loadResearchkeywords() {
		Set<Researchkeyword> response = null;
		response = service.loadResearchkeywords();
		// TODO: JUnit - Add assertions to test outputs of operation: loadResearchkeywords
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
